package com.ruoyi.web.xjgj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.xjgj.domain.CameraAlarmInfo;
import com.ruoyi.web.xjgj.service.ICameraAlarmInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 摄像头告警消息Controller
 *
 * @author ruoyi
 * @date 2025-09-19
 */
@RestController
@RequestMapping("/system/cameraAlarm")
public class CameraAlarmInfoController extends BaseController
{
    @Autowired
    private ICameraAlarmInfoService cameraAlarmInfoService;

    /**
     * 查询摄像头告警消息列表
     */
    @PreAuthorize("@ss.hasPermi('system:cameraAlarm:list')")
    @GetMapping("/list")
    public TableDataInfo list(CameraAlarmInfo cameraAlarmInfo)
    {
        startPage();
        List<CameraAlarmInfo> list = cameraAlarmInfoService.selectCameraAlarmInfoList(cameraAlarmInfo);
        return getDataTable(list);
    }

    /**
     * 导出摄像头告警消息列表
     */
    @PreAuthorize("@ss.hasPermi('system:cameraAlarm:export')")
    @Log(title = "摄像头告警消息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CameraAlarmInfo cameraAlarmInfo)
    {
        List<CameraAlarmInfo> list = cameraAlarmInfoService.selectCameraAlarmInfoList(cameraAlarmInfo);
        ExcelUtil<CameraAlarmInfo> util = new ExcelUtil<CameraAlarmInfo>(CameraAlarmInfo.class);
        util.exportExcel(response, list, "摄像头告警消息数据");
    }

    /**
     * 获取摄像头告警消息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cameraAlarm:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cameraAlarmInfoService.selectCameraAlarmInfoById(id));
    }

    /**
     * 新增摄像头告警消息
     */
    @PreAuthorize("@ss.hasPermi('system:cameraAlarm:add')")
    @Log(title = "摄像头告警消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CameraAlarmInfo cameraAlarmInfo)
    {
        return toAjax(cameraAlarmInfoService.insertCameraAlarmInfo(cameraAlarmInfo));
    }

    /**
     * 修改摄像头告警消息
     */
    @PreAuthorize("@ss.hasPermi('system:cameraAlarm:edit')")
    @Log(title = "摄像头告警消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CameraAlarmInfo cameraAlarmInfo)
    {
        return toAjax(cameraAlarmInfoService.updateCameraAlarmInfo(cameraAlarmInfo));
    }

    /**
     * 删除摄像头告警消息
     */
    @PreAuthorize("@ss.hasPermi('system:cameraAlarm:remove')")
    @Log(title = "摄像头告警消息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cameraAlarmInfoService.deleteCameraAlarmInfoByIds(ids));
    }
}
